Refactor block event handling and add load_model gizmo support#467
Refactor block event handling and add load_model gizmo support#467tracygardner merged 2 commits intomainfrom
Conversation
- Add load_model to scale gizmo switch case in gizmos.js so dragging the scale gizmo creates/updates a resize block in the DO section, consistent with load_character/load_object/load_multi_object - Update load_model block handler to use handleParentLinkedUpdate alongside handleFieldOrChildChange, matching the load_multi_object pattern so BLOCK_CREATE events on value-input children (e.g. connecting a number block to X/Y/Z/SCALE) also trigger mesh updates https://claude.ai/code/session_01CVKFvSifik74xZnSM6Fdwp
|
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: defaults Review profile: CHILL Plan: Pro Run ID: 📒 Files selected for processing (1)
📝 WalkthroughWalkthroughEvent-processing for Changes
Sequence Diagram(s)sequenceDiagram
rect rgba(200,200,255,0.5)
Actor Client
end
rect rgba(200,255,200,0.5)
Participant BlockHandler
Participant MeshLifecycleHandler
Participant ParentLinkedHandler
Participant FieldChildHandler
end
Client->>BlockHandler: emit changeEvent
BlockHandler->>MeshLifecycleHandler: check & handle lifecycle (if changeEvent.blockId === this.id or isThisBlockCreated)
alt Mesh lifecycle consumed
MeshLifecycleHandler-->>BlockHandler: handled
BlockHandler-->>Client: return (stop)
else Not consumed
BlockHandler->>ParentLinkedHandler: handleParentLinkedUpdate(this, changeEvent)
alt ParentLinkedHandler handled
ParentLinkedHandler-->>BlockHandler: handled
BlockHandler-->>Client: return (stop)
else
BlockHandler->>FieldChildHandler: handleFieldOrChildChange(this, changeEvent)
alt Field/child handled
FieldChildHandler-->>BlockHandler: handled
BlockHandler-->>Client: return (stop)
else
BlockHandler-->>Client: continue other processing
end
end
end
Estimated code review effort🎯 3 (Moderate) | ⏱️ ~25 minutes Possibly related PRs
Poem
🚥 Pre-merge checks | ✅ 2 | ❌ 1❌ Failed checks (1 warning)
✅ Passed checks (2 passed)
✏️ Tip: You can configure your own custom pre-merge checks in the settings. ✨ Finishing Touches📝 Generate docstrings
🧪 Generate unit tests (beta)
Comment |
Use `modelName__block.id` as meshId (matching load_object/load_character/ load_multi_object) so that after clearMeshMaps() is called, the meshMap re-population via block.id matches the mesh's metadata.blockKey — allowing the scale gizmo's onDragEndObservable to look up the block correctly. https://claude.ai/code/session_01CVKFvSifik74xZnSM6Fdwp
Deploying flockdev with
|
| Latest commit: |
0a1f606
|
| Status: | ✅ Deploy successful! |
| Preview URL: | https://0a8fa149.flockdev.pages.dev |
| Branch Preview URL: | https://claude-model-block-live-upda.flockdev.pages.dev |
Summary
This PR improves the event handling logic in block models and extends gizmo support to include the
load_modeltype.Key Changes
Refactored block event handling in
blocks/models.js:handleMeshLifecycleChangecheck to execute first when the event targets this block or represents a block creationhandleParentLinkedUpdateandhandleFieldOrChildChangechecks into a single conditional blockthis.id !== changeEvent.blockId && changeEvent.type !== Blockly.Events.BLOCK_CHANGE && !isThisBlockCreatedAdded
load_modelgizmo case inui/gizmos.js:load_modelcase alongside existing model loading cases (load_multi_object,load_object,load_character)Implementation Details
The refactoring in
blocks/models.jsimproves code clarity by:https://claude.ai/code/session_01CVKFvSifik74xZnSM6Fdwp
Summary by CodeRabbit